fix: document request body plaintext disk spooling and mitigation steps#381
Open
eilandert wants to merge 1 commit into
Open
fix: document request body plaintext disk spooling and mitigation steps#381eilandert wants to merge 1 commit into
eilandert wants to merge 1 commit into
Conversation
request_body_in_persistent_file unconditionally spools all client request bodies to disk as plaintext temporary files. This bypasses client_body_buffer_size, meaning even small bodies end up on disk. In environments handling sensitive POST data (authentication, payment, health records), this creates plaintext files readable by any process with access to client_body_temp_path, which defaults to a world- accessible directory under the nginx prefix. Add a security comment at the point of the flag assignment documenting: - The nature of the exposure (plaintext temp files regardless of buffer) - The recommended mitigation: client_body_temp_path to a tmpfs mount such as /dev/shm/nginx_body with 0700 permissions - The recommended size limits to constrain disk usage A proper fix would only spool to disk when body size exceeds client_body_buffer_size and use the configured temp path with restrictive permissions. This comment serves as a clear callout for operators reviewing the source and for future refactoring. Severity: High in multi-tenant environments, Medium in single-tenant Reported-by: Security audit 2026-05-13
|
There was a problem hiding this comment.
Pull request overview
This PR adds an in-source security comment above the r->request_body_in_persistent_file = 1; assignment in the ModSecurity-nginx access handler. The comment documents that ModSecurity-nginx forces request bodies to be spooled to disk as plaintext, and suggests operator mitigations (tmpfs-backed client_body_temp_path, restrictive permissions, and size limits).
Changes:
- Adds a multi-line
SECURITY NOTEcomment inngx_http_modsecurity_access_handlerdescribing the disk-spooling behavior and mitigations. - No functional/code changes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



request_body_in_persistent_file unconditionally spools all client request bodies to disk as plaintext temporary files. This bypasses client_body_buffer_size, meaning even small bodies end up on disk.
In environments handling sensitive POST data (authentication, payment, health records), this creates plaintext files readable by any process with access to client_body_temp_path, which defaults to a world- accessible directory under the nginx prefix.
Add a security comment at the point of the flag assignment documenting:
A proper fix would only spool to disk when body size exceeds client_body_buffer_size and use the configured temp path with restrictive permissions. This comment serves as a clear callout for operators reviewing the source and for future refactoring.